<template>
  <div>
    <canvas width="300px" height="300px" style="width: 300px; height: 300px;" ref="qrcodeCanvas"></canvas>
  </div>
</template>
   
  <script>
import QRCode from "qrcode";

export default {
  name: "QrCodeComponent",
  props: {
    text: {
      type: String,
      required: true,
    },
  },
  mounted() {
    console.log(this.text);
    this.generateQRCode();
  },
  methods: {
    generateQRCode() {
      const canvas = this.$refs.qrcodeCanvas;
      QRCode.toCanvas(canvas, this.text, (error) => {
        if (error) console.error(error);
      });
    },
  },
};
</script>